package com.jymj.service.impl;

import com.jymj.dao.SysProjXzqDao;
import com.jymj.entity.SysXzqEntity;
import com.jymj.service.SysProjXzqService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by ljj on 2017/6/1.
 */
@Service("sysXzqRoleService")
public class SysProjXzqServiceImpl implements SysProjXzqService {

    @Autowired
    private SysProjXzqDao sysProjXzqDao;

    @Override
    public List<Long> queryXzqIdList(Long roleId) {
        return sysProjXzqDao.queryXzqIdList(roleId);
    }

    @Override
    public void saveOrUpdate(Long roleId, List<Long> xzqIdList) {
    }

    @Override
    public List<SysXzqEntity> queryXzqList(Long userId) {
        return sysProjXzqDao.queryXzqList(userId);
    }

    @Override
    public void save(Integer projId, List<Long> xzqIdList) {
        if (xzqIdList == null) {
            return;
        }
        Map<String, Object> map = new HashMap<>();
        map.put("projId", projId);
        map.put("xzqIdList", xzqIdList);
        sysProjXzqDao.save(map);
    }

    @Override
    public void update(Integer pjid, List<Long> xzqIdList) {
        if (xzqIdList == null || xzqIdList.size()<=0) {
            return;
        }
        sysProjXzqDao.delete(pjid);

        Map<String, Object> map = new HashMap<>();
        map.put("projId", pjid);
        map.put("xzqIdList", xzqIdList);
        sysProjXzqDao.save(map);
    }

    @Override
    public List<String> quetyCodeByPjid(Integer pjid) {
        return sysProjXzqDao.quetyCodeByPjid(pjid);
    }
}
